package demotest1;

import java.util.Scanner;

public class Main {                    // 1. 类名大写
	public static void main(String[] args) {
		Scanner scan = null;
		try {
			scan = new Scanner(System.in);
			System.out.print("please input int n: ");
			int n = scan.nextInt();
			int count = 0;
			for (int i = 0; i <= n; ++i) {
				count += i;
			}
			System.out.println("result:" + count);
		} catch (NullPointerException e) {   // 2. 正确 catch 语法
			System.out.println("NullPointerError: " + e.getMessage());
		} finally {
			if (scan != null) {
				scan.close();
			}
		}
	}
}
